package cn.yuanqiao.web.controller.archive.appManager;/**
 * @author 赵常飞
 * @date 2024/1/25 16:00
 */

import cn.yuanqiao.archive.appManager.domain.TenantGdfwAndBgqx;
import cn.yuanqiao.archive.appManager.domain.TenantGdfwAndBgqxRule;
import cn.yuanqiao.archive.appManager.service.ITenantGdfwAndBgqxService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.web.page.TableDataInfo;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 *@Author: 赵常飞
 *@Date: 2024/1/25 16:00
 *@Description:
 *@Note:
 */
@RestController
@RequestMapping("/archive/gdfwandbgqx")
public class TenantGdfwAndBgqxController  extends BaseController {
    @Autowired
    private ITenantGdfwAndBgqxService iTenantGdfwAndBgqxService;
    @Log(title = "获取归档范围和保管期限树", businessType = BusinessType.SELECT)
    @GetMapping("/gettree/{categoryId}")
    public AjaxResult getcatemodeltree(@PathVariable("categoryId") Long categoryId){
        return success(iTenantGdfwAndBgqxService.selectTreeList(categoryId));
    }


    @Log(title = "新增制度", businessType = BusinessType.INSERT)
    @PostMapping("/addzd")
    public AjaxResult addzd(@RequestBody TenantGdfwAndBgqx gdfwAndBgqx){
        return success(iTenantGdfwAndBgqxService.addzd(gdfwAndBgqx));
    }

    @Log(title = "修改制度", businessType = BusinessType.UPDATE)
    @PostMapping("/editzd")
    public AjaxResult editzd(@RequestBody TenantGdfwAndBgqx gdfwAndBgqx){
        return success(iTenantGdfwAndBgqxService.editzd(gdfwAndBgqx));
    }


    @Log(title = "查询制度列表", businessType = BusinessType.SELECT)
    @GetMapping("/gettable/{parentId}/{categoryId}")
    public TableDataInfo gettable(@PathVariable(value = "parentId") Long parentId,@PathVariable(value = "categoryId") Long categoryId)
    {
        startPage();
        List<TenantGdfwAndBgqx> list = iTenantGdfwAndBgqxService.gettable(parentId,categoryId);
        return getDataTable(list);
    }

    @Log(title = "新增制度条件", businessType = BusinessType.INSERT)
    @PostMapping("/addtj")
    public AjaxResult addtj(@RequestBody TenantGdfwAndBgqxRule gdfwAndBgqx){
        return success(iTenantGdfwAndBgqxService.addtj(gdfwAndBgqx));
    }

    @Log(title = "修改制度条件", businessType = BusinessType.UPDATE)
    @PostMapping("/edittj")
    public AjaxResult edittj(@RequestBody TenantGdfwAndBgqxRule gdfwAndBgqx){
        return success(iTenantGdfwAndBgqxService.edittj(gdfwAndBgqx));
    }

    @Log(title = "获取制度条件列表", businessType = BusinessType.SELECT)
    @GetMapping("/gettjtable")
    public TableDataInfo gettjtable(@RequestParam("zdId") Long zdId,@RequestParam("type") Integer type){
        startPage();
        List<Map<String,Object>> list = iTenantGdfwAndBgqxService.gettjtable(zdId,type);
        return getDataTable(list);
    }
    @Log(title = "获取制度详细信息", businessType = BusinessType.UPDATE)
    @PostMapping("/getzd")
    public AjaxResult getzd(@RequestParam("id") Long zdid){
        return success(iTenantGdfwAndBgqxService.getzd(zdid));
    }

    @GetMapping("/gettjsql")
    public AjaxResult gettjsql(@RequestParam("zdId") Long zdId,@RequestParam("type") Integer type){
        return success(iTenantGdfwAndBgqxService.gettjsql(zdId,type));
    }
    @GetMapping("/delete/{tjid}")
    public AjaxResult delete(@PathVariable("tjid") Long tjid){
        return success(iTenantGdfwAndBgqxService.delete(tjid));
    }
    //获取能影响到bgqx的字段
    @GetMapping("/getfieldbycategoryid")
    public AjaxResult getfieldbycategoryid(@RequestParam("categoryId") Long categoryId,@RequestParam("type") Integer type){
        return success(iTenantGdfwAndBgqxService.getfieldbycategoryid(categoryId,type));
    }
    //当著录项字段变化时,返回对应的保管期限
    @PostMapping("/getbgqxbyfile")
    public AjaxResult getbgqxbyfile(@RequestBody JSONObject json){
        return success(iTenantGdfwAndBgqxService.getbgqxbyfile(json));
    }

}
